/**
 * \file MapDisplay.h
 * \brief Header for the \a MapDisplay class.
 * \ingroup Gui
 * \ingroup Map
 */

#ifndef MAPDISPLAY_H
#define MAPDISPLAY_H

#include<QGraphicsEllipseItem>
#include<QGraphicsPathItem>
#include<QGraphicsScene>
#include<QGraphicsView>
#include<QMap>

class Map;
class QTimer;
class QGraphicsItemAnimation;
#include"Field.h"

/**
 * \class MapDisplay
 * \brief Class used to visualize a \a Map and everything happening on it, including \a Unit s and combat.
 * \ingroup Gui
 * \ingroup Map
 */

class MapDisplay: public QGraphicsView{
Q_OBJECT
public:
	MapDisplay(Map *map);///<Constructor. \param map The \a Map to visualize.
	~MapDisplay();///<Destructor.
	
	bool doTurn();///<Causes current \a Unit to do its turn.
	
	const Map *map()const{ return m_map; }///<Returns the \a Map it's visualizing.
	
	void showDistances();///<Debug helper function. Shows distances of all tiles to \a Field occupied by current \a Unit.
	void hideDistances();///<Debug helper function. Hides distances when shown.
private slots:
	void slotUnitDamaged(Unit *unit);///<Causes visualization of a \a Unit taking damage. \param unit The damaged \a Unit.
	void slotTurnEnded(Unit *unit);///<Causes us to be informed of a \a Unit 's turn ending. \param unit The \a Unit whose turn ended.
	void slotTimerTimeout();///<Used to control some graphical bling-bling.
private:
	QGraphicsScene *m_scene;
	Map *m_map;
	QGraphicsEllipseItem ***m_fields;
	QMap<Unit*,QGraphicsTextItem*> m_textItemMap;
	QGraphicsPathItem *m_pathItem;
	QGraphicsTextItem ***m_distances;
	
	QList<QGraphicsItemAnimation*> m_animations;
	QList<QTimer*> m_timers;
	QList<int> m_counters;
	
	QBrush brushForFieldType(FieldType type);
};

#endif
